package org.codeart.map.controller;

import org.codeart.common.util.R;
import org.codeart.common.request.EstimatedPriceDTO;
import org.codeart.common.response.DirectionResponse;
import org.codeart.map.service.DirectionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/direction")
public class DirectionController {
    
    @Autowired
    private DirectionService directionService;
    
    @PostMapping("/driving")
    public R<DirectionResponse> direction(@RequestBody EstimatedPriceDTO estimatedPriceDTO) {
        String depLongitude = estimatedPriceDTO.getDepLongitude();
        String depLatitude = estimatedPriceDTO.getDepLatitude();
        String destLongitude = estimatedPriceDTO.getDestLongitude();
        String destLatitude = estimatedPriceDTO.getDestLatitude();
        DirectionResponse directionResponse = directionService.driving(depLongitude, depLatitude, destLongitude, destLatitude);
        return R.ok(directionResponse);
    }

}
